package com.network.topo.descover;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class NodeThreadPool {
	
	private static ExecutorService pool =  Executors.newFixedThreadPool(15);;

	
	private static Map<String,NodeThread> threadMap = new HashMap<String,NodeThread>();
	public static int ipCount = 0;
	public static void run(NodeThread thread){
		try{
			threadMap.put(thread.getId(),thread);
			
			pool.execute(thread);
			
		}
		catch(Exception ex){
			
		}
	}
	public static void init(){
		threadMap.clear();
		ipCount = 0;
	}
	public static void shutDown(){
		pool.shutdown();
	}
	public static synchronized  void removeOne(String id){
		threadMap.remove(id);
		ipCount++;
	
	}
	public static  boolean isShutdown(){
		return pool.isShutdown();
	
	}
	public static boolean isAlive(){
		return threadMap.size() >0 ?true:false;
	
	}
	public static boolean isTerminated(){
		return pool.isTerminated();
	
	}
}
